<!DOCTYPE html>
<html lang="en">

<head>
  <title>YelpCamp</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
    crossorigin="anonymous">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ"
    crossorigin="anonymous">
  <link href="https://fonts.googleapis.com/css?family=PT+Sans:400,700" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="/stylesheets/main.css">
</head>

<body>
  <nav id="mainNavbar" class="navbar navbar-expand-lg navbar-dark bg-danger">
    <div class="container">
      <% if (!currentUser) { %>
      <a class="navbar-brand" href="/">YelpCamp</a>
      <% } else { %>
        <a class="navbar-brand" href="/campgrounds">YelpCamp</a>
      <% } %>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
        aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
          <li id="home" class="nav-item">
            <a class="nav-link" href="/campgrounds">Campgrounds</a>
          </li>
          <li id="about" class="nav-item">
            <a class="nav-link" href="/about">About</a>
          </li>
          <li id="newCampground" class="nav-item">
            <a class="nav-link" href="/campgrounds/new">New</a>
          </li>
        </ul>
        <ul class="navbar-nav ml-auto">
          <% if(!currentUser) { %>
            <li id="login" class="nav-item">
              <a class="nav-link" href="/login">Login</a>
            </li>
            <li id="register" class="nav-item">
              <a class="nav-link" href="/register">Sign Up</a>
            </li>
          <% } else { %>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true"
                aria-expanded="false">
                <i class="fas fa-user"></i>
                <%= currentUser.username %>
              </a>
              <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                <a class="dropdown-item" href="/users/<%= currentUser._id %>">Profile</a>
                <a class="dropdown-item" href="/logout">Log Out</a>
              </div>
            </li>
          <% } %>
        </ul>
      </div>
    </div>
  </nav>